#!/usr/bin/env python

import sqlalchemy as sa
import sqlalchemy.orm as sao

from datetime import datetime
from model import DeclarativeBase

__all__ = ['Tag']

class Tag(DeclarativeBase):
    '''Tag class
    
    @author Julot <andy.julot@gmail.com>
    @since Wednesday, March 14, 2012. 05:28 PM'''
    
    __tablename__ = 'tags'
        
    id = sa.Column(sa.Integer, primary_key=True)
    name = sa.Column(sa.String(64), nullable=False, unique=True, index=True)
    createdAt = sa.Column(sa.DateTime, default=datetime.now)
    updatedAt = sa.Column(sa.DateTime, default=datetime.now,
                          onupdate=datetime.now)
    
    searchs = sao.relationship('Search', backref='tags')